package com.limeng.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class loginServlet
 */
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public LoginServlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType( "text/html" );
		PrintWriter out = response.getWriter();
		out.println( "<html><body>" );
		String name = request.getParameter("nameS");
		String password = request.getParameter("passwordS");
			out.println("<html><body>");
			if(name.equals(password))
			{
			out.println( "<h1> "+ "Servlet Hello, Mr "+name+"</h1>" );
			response.sendRedirect("JSP/accueil.jsp");
			}
			else
			{
			out.println( "<h1> "+ "Servlet Sorry, the user name or password is not correct"+"</h1>" );
			}
			
			out.println("<html><body>");

		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
